package com.robotic.sensor.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.robotic.common.annotation.Excel;
import com.robotic.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;

/**
 * 传感器数据对象 sensor_data
 * 
 * @author robotic
 * @date 2024-01-20
 */
@TableName("sensor_data")
public class SensorData extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    @TableId(type = IdType.AUTO)
    private Long id;

    /** 区域代码 */
    @Excel(name = "区域代码")
    private String regionCode;

    /** 传感器类型(temperature/gas) */
    @Excel(name = "传感器类型", readConverterExp = "temperature=温度,gas=气体")
    private String sensorType;

    /** 检测值 */
    @Excel(name = "检测值")
    private BigDecimal value;

    /** 检测时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "检测时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date detectTime;

    /** 检测状态(normal/warning/danger) */
    @Excel(name = "检测状态", readConverterExp = "normal=正常,warning=警告,danger=危险")
    private String detectStatus;

    /** 是否符合标准(1符合 0不符合) */
    @Excel(name = "是否符合标准", readConverterExp = "1=符合,0=不符合")
    private String isStandard;

    /** X坐标 */
    @Excel(name = "X坐标")
    private BigDecimal coordinateX;

    /** Y坐标 */
    @Excel(name = "Y坐标")
    private BigDecimal coordinateY;

    /** Z坐标 */
    @Excel(name = "Z坐标")
    private BigDecimal coordinateZ;

    /** 机器人ID */
    @Excel(name = "机器人ID")
    private String robotId;

    /** 任务ID */
    @Excel(name = "任务ID")
    private String taskId;

    /** 处理状态(0未处理 1已处理) */
    @Excel(name = "处理状态", readConverterExp = "0=未处理,1=已处理")
    private String handleStatus;

    /** 处理时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "处理时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date handleTime;

    /** 处理人 */
    @Excel(name = "处理人")
    private String handleBy;

    /** 处理备注 */
    @Excel(name = "处理备注")
    private String handleRemark;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("create_time")
    private Date createTime;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setRegionCode(String regionCode) 
    {
        this.regionCode = regionCode;
    }

    public String getRegionCode() 
    {
        return regionCode;
    }
    public void setSensorType(String sensorType) 
    {
        this.sensorType = sensorType;
    }

    public String getSensorType() 
    {
        return sensorType;
    }
    public void setValue(BigDecimal value) 
    {
        this.value = value;
    }

    public BigDecimal getValue() 
    {
        return value;
    }
    public void setDetectTime(Date detectTime) 
    {
        this.detectTime = detectTime;
    }

    public Date getDetectTime() 
    {
        return detectTime;
    }
    public void setDetectStatus(String detectStatus) 
    {
        this.detectStatus = detectStatus;
    }

    public String getDetectStatus() 
    {
        return detectStatus;
    }
    public void setIsStandard(String isStandard) 
    {
        this.isStandard = isStandard;
    }

    public String getIsStandard() 
    {
        return isStandard;
    }
    public void setCoordinateX(BigDecimal coordinateX) 
    {
        this.coordinateX = coordinateX;
    }

    public BigDecimal getCoordinateX() 
    {
        return coordinateX;
    }
    public void setCoordinateY(BigDecimal coordinateY) 
    {
        this.coordinateY = coordinateY;
    }

    public BigDecimal getCoordinateY() 
    {
        return coordinateY;
    }
    public void setCoordinateZ(BigDecimal coordinateZ) 
    {
        this.coordinateZ = coordinateZ;
    }

    public BigDecimal getCoordinateZ() 
    {
        return coordinateZ;
    }
    public void setRobotId(String robotId) 
    {
        this.robotId = robotId;
    }

    public String getRobotId() 
    {
        return robotId;
    }
    public void setTaskId(String taskId) 
    {
        this.taskId = taskId;
    }

    public String getTaskId() 
    {
        return taskId;
    }
    public void setHandleStatus(String handleStatus) 
    {
        this.handleStatus = handleStatus;
    }

    public String getHandleStatus() 
    {
        return handleStatus;
    }
    public void setHandleTime(Date handleTime) 
    {
        this.handleTime = handleTime;
    }

    public Date getHandleTime() 
    {
        return handleTime;
    }
    public void setHandleBy(String handleBy) 
    {
        this.handleBy = handleBy;
    }

    public String getHandleBy() 
    {
        return handleBy;
    }
    public void setHandleRemark(String handleRemark) 
    {
        this.handleRemark = handleRemark;
    }

    public String getHandleRemark() 
    {
        return handleRemark;
    }
    public void setCreateTime(Date createTime) 
    {
        this.createTime = createTime;
    }

    public Date getCreateTime() 
    {
        return createTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("regionCode", getRegionCode())
            .append("sensorType", getSensorType())
            .append("value", getValue())
            .append("detectTime", getDetectTime())
            .append("detectStatus", getDetectStatus())
            .append("isStandard", getIsStandard())
            .append("coordinateX", getCoordinateX())
            .append("coordinateY", getCoordinateY())
            .append("coordinateZ", getCoordinateZ())
            .append("robotId", getRobotId())
            .append("taskId", getTaskId())
            .append("handleStatus", getHandleStatus())
            .append("handleTime", getHandleTime())
            .append("handleBy", getHandleBy())
            .append("handleRemark", getHandleRemark())
            .append("createTime", getCreateTime())
            .toString();
    }

    /**
     * 判断传感器数据是否异常
     * @return true-异常，false-正常
     */
    public boolean isAbnormal() {
        return "0".equals(this.isStandard);
    }

    /**
     * 判断传感器数据是否为危险状态
     * @return true-危险，false-非危险
     */
    public boolean isDangerStatus() {
        return "danger".equals(this.detectStatus);
    }

    /**
     * 判断传感器数据是否为警告状态
     * @return true-警告，false-非警告
     */
    public boolean isWarningStatus() {
        return "warning".equals(this.detectStatus);
    }

    /**
     * 判断传感器数据是否已处理
     * @return true-已处理，false-未处理
     */
    public boolean isHandled() {
        return "1".equals(this.handleStatus);
    }
}